package de.baumann.browser.activitys.center

import android.content.Context
import android.content.Intent
import android.support.v7.widget.LinearLayoutManager
import de.baumann.browser.R
import de.baumann.browser.activitys.center.WithdrawDetailActivity.Companion.startWithdrawDetailActivity
import de.baumann.browser.activitys.center.WithdrawProgressActivity.Companion.startWithdrawProgressActivity
import de.baumann.browser.adapter.WithdrawalsRecordAdapter
import de.baumann.browser.api.net.vo.OdinWithdrawRecord
import de.baumann.browser.base.BaseOdinActivity
import de.baumann.browser.iview.IWithdrawRecordView
import de.baumann.browser.present.WithdrawRecordPresenter
import de.baumann.browser.utils.ViewUtil
import kotlinx.android.synthetic.main.activity_withdrawals_record_main.*
import kotlinx.android.synthetic.main.include_tool_bar.*

/**
 *@author:
 *@date:2019/7/4 18:53
 *@discription: 新版本 提现记录
 */

@Deprecated("废弃")
class WithdrawalsRecordActivity : BaseOdinActivity<IWithdrawRecordView,WithdrawRecordPresenter>(), IWithdrawRecordView {

    private lateinit var withdrawalsRecordAdapter:WithdrawalsRecordAdapter

    companion object {
        fun startWithdrawalsRecordActivity(context: Context) {
            context.startActivity(Intent(context, WithdrawalsRecordActivity::class.java))
        }
    }

    override fun getLayout(): Int {
        return R.layout.activity_withdrawals_record_main
    }

    override fun initView() {
        initToolbar(commToolBar,commTitle)
        rvWithdrawRecord.layoutManager = LinearLayoutManager(mContext)
        withdrawalsRecordAdapter = WithdrawalsRecordAdapter(R.layout.item_withdrawals_record)
        rvWithdrawRecord.adapter = withdrawalsRecordAdapter
        withdrawalsRecordAdapter.emptyView = ViewUtil.emptyView(mContext)
        withdrawalsRecordAdapter.setOnItemClickListener { adapter, _, position ->
           val withdrawRecord =  adapter.getItem(position) as OdinWithdrawRecord
            when(withdrawRecord.status){
                2,3 ->{
                    startWithdrawDetailActivity(mContext,withdrawRecord)
                }

                1 ->{
                    startWithdrawProgressActivity(mContext,withdrawRecord)
                }
            }
        }
    }

    override fun createPresenter(): WithdrawRecordPresenter {
        return WithdrawRecordPresenter()
    }

    override fun createView(): IWithdrawRecordView {
        return this
    }

    override fun initData() {
        presenter.getWithdrawRecord()
    }

    override fun getTitleText(): String {
        return getString(R.string.WithdrawalsRecord)
    }

    override fun setOdinWithdrawLise(withdrawList: List<OdinWithdrawRecord>) {
        withdrawalsRecordAdapter.setNewData(withdrawList)
    }

    override fun setOdinOverage(overage: String) {

    }
}
